#include "Undoable.h"
#include <iostream>

using namespace std;

int Undoable :: count = 0;
Undoable* Undoable :: undoableCmd[UNDO_NUM];

Undoable :: Undoable()
{
	if(count >= UNDO_NUM)
	{
		cout << "Out of Memeory! Clearing command history...\n";
		for(int i = 0; i < count; i++)
		{
			delete undoableCmd[i];
		}
		count = 0;
	}

	undoableCmd[count++] = this;
}

Undoable* Undoable :: getLastCmd()
{
	if(count > 0)
		return undoableCmd[--count];
	else
		return NULL;
}